package com.keafmd.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @author chenji
 * @date 2022/1/5 15:28
 */
public class ConverterTest implements Converter<String> {

    @Override
    public Class supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
            GlobalConfiguration globalConfiguration) throws Exception {
        return cellData.getStringValue().equals("1")?"男":"女";
    }

    @Override
    public CellData convertToExcelData(String s, ExcelContentProperty excelContentProperty,
            GlobalConfiguration globalConfiguration) throws Exception {

        return new CellData(s.equals("1")?"男":"女");
    }
}
